(* Initialisation de lablGTK *)
let window = 
	GMain.init (); 
  
(* Creation de la fenetre *)
let wnd = GWindow.window 
    	~title:"PimMyMap" 
    	~position:`CENTER 
    	~resizable:true 
    	~width:800 
	~height:500 () in 
  	wnd#connect#destroy GMain.quit; 
	wnd 

(* Boite contenant les widgets *)
let box = GPack.vbox
	~spacing:5
	~packing:window#add ()

let image_box = GPack.vbox
	~spacing:5
	~border_width:5
	~packing:box#add ()

let img file () = GMisc.image 
	~file:file
	~width:790
	~height:590
	~packing:image_box#add ()


(* Filtre de format pour l'ouverture d'un nouveau fichier *)
let img_filter () = GFile.filter
	~name:"Map Files"
	~patterns:[ "*.bmp" ; "*.jpg"] () 


let display_img btn () = Gaux.may img btn#filename

let toolbox = GPack.button_box `VERTICAL
	~spacing:5
	~layout: `EDGE
	~child_width:290
	~child_height:50
	~packing:(box#pack ~expand:false) ()


let open_b = 
	let button = GFile.chooser_button
		~action: `OPEN
		~packing:toolbox#add () in
	button#set_filter (img_filter ());
	button#connect#selection_changed (display_img button);
	button



let quit_b =
	let button = GButton.button
		~stock: `QUIT
		~packing:toolbox#add () in
	button#connect#clicked ~callback:GMain.quit;
	button



let main () =
begin
	window#show (); 
  	GMain.main ();
	exit 0 
end

(* Point d'entrée *)
let _ =
	main ();
